<template>
  <div>
    <input type="text" v-model="text" />
    <button @click="jia">添加</button>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { useStore } from "../stores/userStore";

const todo = useStore()
const text = ref('');

const jia = () => {
  todo.add(text.value)
  text.value = ''
}
</script>

<!-- <script>
import { mapActions } from "pinia";
import { useStore } from "../stores/userStore";
export default {
  data() {
    return {
      text: ''
    }
  },
  methods: {
    ...mapActions(useStore, ['add']),

    jia() {
      this.add(this.text)
      this.text = ''
    }
  }
}
</script> -->